package org.example.lyx2022.service;

import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.session.SqlSession;
import org.example.lyx2022.dao.userdao;
import org.example.lyx2022.domain.user;
import org.example.lyx2022.utils.MybatisUtil;
import org.springframework.stereotype.Service;

@Service
public class sqlservice {
    public String adduser(String no,String name) {
        try (SqlSession session = MybatisUtil.getSqlSession()) {
            userdao mapper = session.getMapper(userdao.class);
            int list = mapper.adduser(no,name);
            JSONObject jsonObject=new JSONObject();
            jsonObject.put("data",list);

            return jsonObject.toJSONString();
        } catch (Exception e) {
            throw new RuntimeException("查询过程中出现异常", e);
        }
    }
}
